package com.netistate.pojo;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name="t_user")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class User {
	
	private int id;
	private String username;
	private String password;
	private String realName;
	private String email;
	private String tel;
	
	
	private Set<Labor> LaborList;
	private List<UserProject> userProjectList;
	
	
	@OneToMany(mappedBy="user")
	public List<UserProject> getUserProjectList() {
		return userProjectList;
	}
	public void setUserProjectList(List<UserProject> userProjectList) {
		this.userProjectList = userProjectList;
	}
	/*private List<Project> projectList;
	
	//n:n
	@ManyToMany
	@JoinTable(name="t_user_project",
	joinColumns=@JoinColumn(name="projectid"),
	inverseJoinColumns=@JoinColumn(name="userid")
	)
	public List<Project> getProjectList() {
		return projectList;
	}
	public void setProjectList(List<Project> projectList) {
		this.projectList = projectList;
	}*/
	//1:n
	@OneToMany(mappedBy="user",cascade={CascadeType.ALL},fetch=FetchType.LAZY)
	public Set<Labor> getLaborList() {
		return LaborList;
	}
	public void setLaborList(Set<Labor> laborList) {
		LaborList = laborList;
	}
	
	
	//get set
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	
	
}
